define([
    'request',
    'template',
    'jquery',
    'zPages'
], function(request,template) {
    class Zpages{
        constructor(){
            this.init()
            window.request=request
            window.template=template
           
        }
        init(){
            $("#pager").zPager({
                totalData: 50,
                htmlBox: $('#wraper'),
                btnShow: true,
                ajaxSetData: false
            });
        }
       
    }
    return new Zpages()
});

let init=0
function currentPage(currentPage){
    const num= 20*(currentPage-1)
    let id=0
    let search=''
    if(location.search.includes('search')){
        search=location.search.slice(8)
      }else if(location.search.includes('id')){
        id=location.search.slice(4)
      }
    if(init===1){
        request.getUpdata(num,id,search).then(val=>{
            if(val.code===200){
                const list=val.data.list.slice(0,20)
                const {data}=val
                $('#list_shopList_warp').html(template('list_shopList',{list,data}))
            }
        })
    }
    if(currentPage>=2){
        init=1
        request.getUpdata(num,id,search).then(val=>{
            if(val.code===200){
                const list=val.data.list.slice(0,20)
                const {data}=val
                $('#list_shopList_warp').html(template('list_shopList',{list,data}))
            }
        })
    }
}
   